import { ImageResponse } from 'next/og';
import { Fallback, Wallpaper } from '@/components/brand/og';
import { apiD1, safe } from '@/lib/api';
import { fmtInt } from '@/lib/format';
import { SITE_NAME } from '@/lib/site';
export const runtime = 'nodejs';
export const alt = `Licence on ${SITE_NAME}`;
export const size = { width: 1200, height: 630 };
export const contentType = 'image/png';
const tri = (v: boolean | null) => (v === true ? 'Yes' : v === false ? 'No' : 'Unknown');
export default async function LicenseOgImage({ params }: { params: Promise<{ key: string }> }) {
const { key } = await params;
const l = await safe(apiD1.license(key, 1));
if (!l) return new ImageResponse(, { ...size });
const counters: [string, string][] = [
['Commercial use', tri(l.commercial_use)],
['Redistribution', tri(l.redistribution)],
['Derivatives', tri(l.derivatives)],
['Models', fmtInt(l.models?.total ?? 0)],
];
const subtitle = [l.category, l.spdx ? `SPDX ${l.spdx}` : null, l.osi_approved ? 'OSI approved' : null, l.weights_downloadable ? 'weights downloadable' : 'weights not downloadable'].filter(Boolean).join(' · ');
return new ImageResponse(, { ...size });
}